package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.TownClassifyRequest;
import cn.stylefeng.guns.modular.business.service.TownClassifyService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 城镇分类表控制器
 *
 * @author zhangyaowen
 * @date 2021/10/25 16:46
 */
@RestController
@ApiResource(name = "城镇分类表")
public class TownClassifyController {

    @Resource
    private TownClassifyService townClassifyService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "添加", path = "/townClassify/add")
    public ResponseData add(@RequestBody @Validated(TownClassifyRequest.add.class) TownClassifyRequest townClassifyRequest) {
        townClassifyService.add(townClassifyRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "删除", path = "/townClassify/delete")
    public ResponseData delete(@RequestBody @Validated(TownClassifyRequest.delete.class) TownClassifyRequest townClassifyRequest) {
        townClassifyService.del(townClassifyRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "编辑", path = "/townClassify/edit")
    public ResponseData edit(@RequestBody @Validated(TownClassifyRequest.edit.class) TownClassifyRequest townClassifyRequest) {
        townClassifyService.edit(townClassifyRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "查看详情", path = "/townClassify/detail")
    public ResponseData detail(@Validated(TownClassifyRequest.detail.class) TownClassifyRequest townClassifyRequest) {
        return new SuccessResponseData(townClassifyService.detail(townClassifyRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "获取列表", path = "/townClassify/list")
    public ResponseData list(TownClassifyRequest townClassifyRequest) {
        return new SuccessResponseData(townClassifyService.findList(townClassifyRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "分页查询", path = "/townClassify/page")
    public ResponseData page(TownClassifyRequest townClassifyRequest) {
        return new SuccessResponseData(townClassifyService.findPage(townClassifyRequest));
    }

    /**
     * 获取分组检索词
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "获取城镇分类", path = "/townClassify/choose")
    public ResponseData choose() {
        return new SuccessResponseData(townClassifyService.findChoose());
    }

    /**
     * 获取分组检索词
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "获取城镇分类的城镇坐标数据", path = "/townClassify/findTown")
    public ResponseData findTown(String secondCode) {
        return new SuccessResponseData(townClassifyService.findTown(secondCode));
    }
}